<template>
    <div id="box" @scroll="aa" ref="both">
        <nav>
            <span class="fa fa-angle-left" @touchstart="back"></span>
            <span>我的发布</span>
            <span class="fa fa-ellipsis-h" @touchstart="btn"></span>
        </nav>
        <div id="hide" v-show="show">
            <span class="fa fa-caret-up"></span>
            <div id="hide-bottom">
                <router-link to="/second/Message">
                    <div class="one">
                        <span class="fa fa-commenting-o"></span>
                        <span>消息</span>
                    </div>
                </router-link>
                <router-link to="/">
                    <div class="two">
                        <span class="fa fa-home"></span>
                        <span>首页</span>
                    </div>
                </router-link>
            </div>
        </div>
        <div id="content">
            <div id="all">
                <div v-for="s in arr" class="list">
                    <div class="left">
                         <router-link :to="'/Kind/GoodList/Detail/'+s.name">
                        <img :src="s.picture[1]">
                        </router-link>
                    </div>
                    <div class="right">
                        <span class="activity">双11</span>
                        <span>{{s.name}}</span>
                        <p>包邮</p>
                        <p>￥{{s.price}}</p>
                        <p>800人已付款</p>
                        <div class="bottom">
                        <span>{{s.area}}</span>
                        <span class="fa fa-trash" @touchstart="remove(s._id)"></span>
                        </div>
                    </div>
                </div>              
            </div>
        </div>
        <div class="up" v-show="isShow" @touchstart="top">
            <span class="fa fa-long-arrow-up fa-lg"></span>
        </div>
    </div>
</template>

<script>
export default{
    data:function(){
        return{
            arr:[],
            show:false,
            isShow:false
        }
    },
    mounted:function(){
        this.$store.dispatch("requestMine")
        .then(res=>{
            this.arr = res.data.msg;
        })
    },
    methods:{
        back:function(){
            history.back();
        },
        btn:function(){
            this.show = !this.show;
        },
        remove:function(id){
            this.$store.dispatch("requestDelete",{params:{id}})
            .then(res=>{
                layer.msg(res.data.msg);
                this.$store.dispatch("requestMine")
                .then(res=>{
                    this.arr = res.data.msg;
                })
            })
        },
        aa:function(){
            if(this.$refs.both.scrollTop>100){
                this.isShow = true;
            }
        },
        top:function(){
            setTimeout(function() {
                this.$refs.both.scrollTop = 0;
                this.isShow =false;
            }.bind(this), 700);
        }
    }
}
</script>

<style scoped>
    #box{
        background-color: #eee;
        height: 100vh;
        overflow: scroll;
    }
    nav{
        height: 35px;
        line-height: 35px;
        border-bottom: 1px solid #aaa;
        padding: 0 10px;
        display: flex;
        justify-content: space-between;
        z-index: 100;
        background-color: white;
    }
    nav span:nth-of-type(1){
        font-size: 23px;
        margin-top: 5px;
    }
    nav span:nth-of-type(3){
        font-size: 22px;
        margin-top: 8px;
    }
    #conent{
        height: calc(100vh - 35px);
        overflow-y: scroll;
    }
    #hide{
        position: absolute;
        right: 5px;
        top: 8px;
    }
    .fa-caret-up{
        font-size: 25px;
        position: relative;
        top: 9px;
        left: 79px;
        color: rgba(0,0,0,0.75);
    }
    #hide-bottom{
        width: 100px;
        height: 70px;
        border: 1px solid #666;
        color: white;
        background-color: rgba(0,0,0,0.75);
    }
    .one{
        border-bottom: 1px solid #999;
    }
    .two,.one{
        height: 35px;
        line-height: 35px; 
        padding-left: 8px;
    }
    .one span:nth-of-type(2){
        margin-left: 6px;
        font-size: 14px;
    }
    .two span:nth-of-type(2){
        margin-left: 6px;
        font-size: 14px;
    }
    #hide a{
        color: white !important;
        text-decoration: none;
    }
    #all{
        margin-top: 8px;
    }
    #all a{
        text-decoration: none;
        color: black;
    }
    .list{
        display: flex;
        padding: 0 0 2px 0;
        border-bottom: 1px solid #eee;
        margin-bottom: 6px;
        background-color: white;
    }
    .left img{
        width: 110px;
        height: 110px;
    }
    .right{
        margin-left: 8px;
        width: 100%;
    }
    .activity{
        font-size: 12px;
        display: inline-block;
        padding: 0 2px;
        background-color: red;
        color: white;
        border-radius: 3px;
    }
    .right p{
        margin: 0;
    }
    .right p:nth-of-type(1){
        margin-top: 10px;
        font-size: 13px;
        width: 30px;
        border: 1px solid orange;
        color: orange;
    }
    .right p:nth-of-type(2){
        margin-top: 10px;
        display: inline-block;
    }
    .right p:nth-of-type(3){
        display: inline-block;
        margin-left: 15px;
        font-size: 14px;
        color: #999;
    }
    .bottom{
        display: flex;
        justify-content: space-between;
        padding-right: 15px;
    }
    .bottom span:nth-of-type(1){
        margin-top: 5px;
        font-size: 14px;
    }
    .bottom span:nth-of-type(2){
        margin-top: 5px;
        font-size: 18px;
    }
    .up{
        border: 1px solid #999;
        width: 35px;
        height: 35px;
        position: fixed;
        right: 30px;
        bottom: 50px;
        text-align: center;
        font-size: 20px;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.5);
        color: white;
    }
</style>